<template>
  <div class="app-container">
    <info-page-container>
      <template slot="body">
        <list-page-container>
          <template slot="query">
            <el-alert
                :title="message"
                :closable="false"
                type="info">
            </el-alert>
          </template>
          <template slot="table">
            <el-table height="100%" :data="dataList">
              <el-table-column label="投保单号" align="center" prop="uniqueField"/>
              <el-table-column label="导入结果" align="center" prop="resultStr"/>
              <el-table-column label="状态" align="center" prop="success">
                <template slot-scope="scope">
                  <span class="allow" v-if="scope.row.success">成功</span>
                  <span class="notAllow" v-if="!scope.row.success">失败</span>
                </template>
              </el-table-column>
              <el-table-column label="结果说明" align="center" prop="reason"/>
            </el-table>
          </template>
        </list-page-container>
      </template>
    </info-page-container>
  </div>

</template>

<script>
import {sysGetDetail} from "@/api/importTask";

export default {
  name: "importTaskInfoPage",
  data() {
    return {
      taskId: null,
      dataList: [],
      message: ''
    }
  },
  methods: {
    getListData() {
      let {taskId} = this
      if (taskId == null || taskId == '') {
        return
      }
      let owner = this
      owner.startLoading('正在加载....')
      sysGetDetail({id: taskId}).then(res => {
        let {data: {importResult: {taskImportDetails, message}}} = res
        owner.dataList = taskImportDetails;
        owner.message = message
      }).catch((e) => {
        owner.endLoading()
      }).finally(() => {
        owner.endLoading()
      });
    }
  },
  created() {
    this.taskId = this.$route.query?.id != null && this.$route.query?.id !== '' ? this.$route.query.id : null;
    this.getListData()
  }
}
</script>

<style scoped>

</style>
